#include <iostream>
using namespace std;

// 重载关系运算符
class Person
{
public:
    string name;
    int age;

    Person(string name, int age)
    {
        this->name = name;
        this->age = age;
    }

    // 重载 == 号
    bool operator==(Person& p)
    {
        if (this->name == p.name && this->age == p.age)
        {
            return true;
        }
        return false;
    }

    // 重载 != 号
    bool operator!=(Person& p)
    {
        if (this->name == p.name && this->age == p.age)
        {
            return false;
        }
        return true;
    }
    
};

void test1()
{
    Person p1("张三", 18);
    Person p2("张小三", 18);

    cout << "-------重载!=的效果：-------" << endl;
    if (p1 != p2)
    {
        cout << "p1与p2不相等" << endl;
    }
    else
    {
        cout << "p1与p2相等" << endl;
    }

    cout << "-------重载==的效果：-------" << endl;
    if (p1 == p2)
    {
        cout << "p1与p2相等" << endl;
    }
    else
    {
        cout << "p1与p2不相等" << endl;
    }
}

int main()
{
    test1();
    return 0;
}